package com.zch.work.controller;

import com.zch.domain.Result;
import com.zch.entity.TbOperateMould;
import com.zch.work.service.TbOperateMouldService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;

/**
 * @author 28763
 * @version 1.0
 * @description: TODO 作业要素划分
 * @date 2023/10/30 20:04
 */
@RestController
@RequestMapping("/job")
public class OperateMouldController {
    @Autowired
    TbOperateMouldService tbOperateMouldService;

    /**
     * @description: TODO 删除
     * @author 王志赛
     * @date 2023/10/30 21:43
     * @version 1.0
     */
    @PostMapping("/deletedByID")
    public Result deletedByID(@RequestBody TbOperateMould tbOperateMould){
        return tbOperateMouldService.deletedByID(tbOperateMould);
    }

    /**
     * @description: TODO 添加
     * @author 王志赛
     * @date 2023/10/30 21:45
     * @version 1.0
     */
    @PostMapping("/save")
    public Result save(@RequestBody TbOperateMould tbOperateMould){
        return tbOperateMouldService.addOperate(tbOperateMould);
    }

    /**
     * @description: TODO 修改
     * @author 王志赛
     * @date 2023/10/31 8:20
     * @version 1.0
     */
    @PostMapping("/update")
    public Result update(@RequestBody TbOperateMould tbOperateMould){
        return tbOperateMouldService.updateAll(tbOperateMould);
    }

    /**
    * @description: TODO 导出
    * @author 王志赛
    * @date 2023/10/31 10:03
    * @version 1.0
    */
    @GetMapping("/exports")
    public void exports(HttpServletResponse response){

        tbOperateMouldService.exports(response);
    }

    /**
    * @description: TODO  导入
    * @author 王志赛
    * @date 2023/10/31 10:24
    * @version 1.0
    */
    @PostMapping("/import")
    public Result importJob(@RequestPart("file") MultipartFile file) throws Exception {
         return tbOperateMouldService.importJob(file);
    }


}
